/**
 * @Author your name
 * @Date 2021-03-04 10:16:34
 * @LastEditTime 2021-03-04 10:18:24
 * @LastEditors Please set LastEditors
 * @Description In User Settings Edit
 * @FilePath \fed-e-task-04-06\code\angular-route\src\app\guards\get-name.resolver.ts
 */
import { Injectable } from '@angular/core';
import {
  Router, Resolve,
  RouterStateSnapshot,
  ActivatedRouteSnapshot
} from '@angular/router';
import { Observable, of } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class GetNameResolver implements Resolve<string> {
  resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<string> {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve('李四')
      }, 2000);
    })
  }
}
